
%{

#include "list/quadList.h"
#include "list/symbolList.h"
#include "list/intList.h"
#include <stdio.h>
#include "syntacticAnalyzer.h"
#define YY_NO_INPUT /* ok, Ã  accepter sans explication */


int lexvalue; /* contiendra la valeur des entiers recontres */


%}

%option nounput
%option input
%option noyywrap

%%

 /* remove blank */
[\n \t]+ ;

 /* remove comment: */
[(][*]([^*]|[\r\n]|([*]+([^*/]|[\r\n])))*[*]+[)] ;

 /* boolean constant */
true {
  return tok_true;
}
false {
  return tok_false;
}

 /* keyword */
"do" {return tok_do;}
"done" {return tok_done;}
not {return tok_not;}
while {return tok_while;}
begin {return tok_begin;}
end {return tok_end;}
if {return tok_if;}
then {return tok_then;}
else {return tok_else;}
int {return tok_KWint;}
bool {return tok_KWbool;}
ref {return tok_ref;}
rec {return tok_rec;}
let {return tok_let;}
in  {return tok_in;}
and  {return tok_KWand;}
array {return tok_array;}

Array.make {return tok_makeArray;}
print_string {return tok_printString;}
print_int {return tok_printInt;}
read_int {return tok_readInt;}

\( {return tok_op;}
\) {return tok_cp;}
:= {return tok_aff;}
= {return tok_eq;}

: {return tok_colon;}
; {return tok_sep;}
"." {return tok_dot;}
"<-" {return tok_leftArrow;}
"!" {return tok_exclam;}

\- {return tok_minus;}
\+ {return tok_add;}
\* {return tok_mul;}
\/ {return tok_div;}
"<>"|">="|"<="|">"|"<" {
  if (!strcmp("<=",yytext))
    {
      yylval.relVal=Q_IFLEGOTO;
    }
  else if (!strcmp(">=",yytext))
    {
      yylval.relVal=Q_IFGEGOTO;
    }
  else if (!strcmp("<>",yytext))
    {
      yylval.relVal=Q_IFNEQGOTO;
    }
  else if (!strcmp(">",yytext))
    {
      yylval.relVal=Q_IFGTGOTO;
    }
  else if (!strcmp("<",yytext))
    {
      yylval.relVal=Q_IFLTGOTO;
    }
    return tok_rel;
}
"&&" {return tok_andAnd;}
"||" {return tok_orOr;}


 /* numerical const: int */
[0-9]+ {
  yylval.intVal=atoi(yytext);
  return tok_num;
}


 /* string */
\"([^\"]|\\.)*\" {
  yylval.strVal=strdup(yytext);
  return tok_string;
}

 /* id */
 /* (has to be among the last rules for concurent match) */
[a-zA-Z]([a-zA-Z0-9]|\'|_)* {
  yylval.strVal=strdup(yytext);
  return tok_ident;
}

 /* default rule: character not reckognized */
. {
  printf("error: character not recognized: %s\n",yytext);
  exit(0);
 }

%%

